//
//  NLHomePicCollectionView.swift
//  sinaWeibo7110
//
//  Created by 安静清晨 on 2017/1/10.
//  Copyright © 2017年 walk-in-minds. All rights reserved.
//

import UIKit

let homePictureCellID = "homePictureCellID"

class NLHomePicCollectionView: UICollectionView,UICollectionViewDataSource,UICollectionViewDelegate {

    var pic_urls : [NLPicture]?{
        
        didSet{
            
            self.reloadData()
        }
    }
    
    override func awakeFromNib() {
        //不用调用父类方法
        //flag
        self.register(NLPictureCell.self, forCellWithReuseIdentifier: homePictureCellID)
        
        self.backgroundColor = UIColor.clear
        
        self.dataSource = self
    }
    
    
    func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
        
        return pic_urls?.count ?? 0
    }
    
    func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
        
        let cell = collectionView.dequeueReusableCell(withReuseIdentifier: homePictureCellID, for: indexPath) as! NLPictureCell
        cell.pic = self.pic_urls?[indexPath.item]
        return cell
    }
    
    
}
